package com.hdu.controller;

import com.hdu.entity.Dictionary;
import com.hdu.pojo.Result;
import com.hdu.service.IDictionaryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 数据字典 前端控制器
 * </p>
 *
 * @author xiaobai
 * @since 2024-05-20
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class DictionaryController {

    private final IDictionaryService dictionaryService;

    @GetMapping("/dictionary/all")
    public Result<List<Dictionary>> queryAll() {
        return Result.success(dictionaryService.queryAll());
    }

    @GetMapping("/dictionary/code/{code}")
    public Result<Dictionary> getByCode(@PathVariable String code) {
        return Result.success(dictionaryService.getByCode(code));
    }
}
